package test.juc.thread.join;

/**
 * @author zhangrui
 * @date 2020-04-24 20:24
 * @since 1.0
 */
public class Thread1 implements Runnable{

    private Thread thread2 ;

    public Thread1(Thread thread2){
        this.thread2 = thread2 ;
    }

    @Override
    public void run() {
        System.out.println("thread1 begin");
        try {
            System.out.println("thread2 join");
            //意为thread2中途插入了，需要等thread2执行完了，才继续执行thread1
            thread2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("thread1 end");
    }
}
